package com.androidRtc.controller;

import com.androidRtc.dao.RoomDao;
import com.androidRtc.dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class RoomLoginServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String RoomName, Rpassword;
        RoomDao dao = new RoomDao();
        int result = 0;
        //1.调用请求对象对请求体使用utf-8字符集进行重新编辑
        request.setCharacterEncoding("utf-8");
        //2.调用请求对象读取请求体参数信息
        RoomName = request.getParameter("RoomName");
        Rpassword = request.getParameter("Rpassword");
        //3.调用Dao将查询验证信息推送到数据库服务器上
        result = dao.login(RoomName, Rpassword);
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.print(result);
        out.flush();
        out.close();

    }
}
